package com.chen.generator;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;

public class Test1 {
    public static void main(String[] args) throws Exception {
//        System.out.println(System.getProperty("user.dir"));
        Connection conn = DriverManager.getConnection(
                "jdbc:mysql://10.211.55.100:3306/tingshu", "root", "1234");

        DatabaseMetaData metaData = conn.getMetaData();
        System.out.println(metaData);

        ResultSet rs = metaData.getColumns(null, null, "user", null);
        //	null：使用当前连接的数据库；
	 //	"user"：表名；
	// 	null：所有列。
        while (rs.next()) {
            System.out.println(
                    rs.getString("COLUMN_NAME") + " : " +
                            rs.getString("TYPE_NAME") + " (" +
                            rs.getInt("COLUMN_SIZE") + ") " +
                            " -- " + rs.getString("REMARKS"));
        }
    }
}
